using System;
using System.Collections.Generic;
using System.Text;
using HtmlAgilityPack;

namespace CmdXSSScanner
{
    class Program
    {
        static void Main(string[] args)
        {
            testForm();
        }
        static void testForm()
        {
            HtmlWeb hw = new HtmlWeb();
            // get the document from the Internet resource
            Console.WriteLine("Input URL: ");
            String url = Console.ReadLine();
            HtmlDocument doc = hw.Load(url);
            HtmlNodeCollection forms = doc.DocumentNode.SelectNodes("//form");

            if (forms == null)
            {
                Console.WriteLine("No forms founded!");
            }
            else
            {
                foreach (HtmlNode form in forms)
                {
                    Console.WriteLine("FORM: id={0}  action={1}", form.GetAttributeValue("id", ""), form.GetAttributeValue("action", ""));
                    // each form
                    HtmlNodeCollection inputs = form.SelectNodes("//input");
                    if (null == inputs)
                        Console.WriteLine("no input field found");
                    else
                    {
                        int i = 0;
                        foreach (HtmlNode input in inputs)
                        {
                            Console.WriteLine("param {0}: {1}", i++, input.GetAttributeValue("name", ""));
                        }
                    }
                }
            }

        }
    }
}
